package com.sketch.controller;

import com.sketch.commom.PageResult;
import com.sketch.commom.Result;
import com.sketch.entity.dto.DeleteDTO;
import com.sketch.entity.dto.SketchInfoDTO;
import com.sketch.entity.dto.TheaterInfoDTO;
import com.sketch.service.TheaterInfoService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

@RestController
@Api(tags = "剧场管理 API")
@RequestMapping(value = "/api/theater")
public class TheaterController {
    @Resource
    private TheaterInfoService theaterInfoService;
    /**
     * 新增或更新剧场
     */
    @PostMapping("/addOrUpdate")
    @ApiOperation("新增或更新剧场")
    public Result addOrUpdate(@RequestBody TheaterInfoDTO theaterInfoDTO) {
        return theaterInfoService.addOrUpdate(theaterInfoDTO);
    }

    /**
     * 剧场列表
     */
    @GetMapping("/list")
    @ApiOperation("剧场列表")
    public Result<PageResult<TheaterInfoDTO>> list(@ApiParam(value = "名称") @RequestParam(required = false) String name,
                                                  @ApiParam(value = "onlineStatus") @RequestParam(required = false) Integer onlineStatus,
                                                  @RequestParam(value = "page", defaultValue = "1", required = false) Integer page,
                                                  @RequestParam(value = "size", defaultValue = "20", required = false) Integer size) {
        return theaterInfoService.list(name, onlineStatus, page, size);
    }

    /**
     * 剧场详情
     */
    @GetMapping("/detail")
    @ApiOperation("剧场详情")
    public Result<TheaterInfoDTO> detail(@ApiParam(value = "id") @RequestParam Long id){
        return theaterInfoService.detail(id);
    }

    /**
     * 删除
     */
    @GetMapping("/delete")
    @ApiOperation("删除")
    public Result delete(@RequestBody DeleteDTO deleteDTO) {
        return theaterInfoService.delete(deleteDTO.getId());
    }
}
